package com.windea.study.kotlin.jvm.spam

import org.apache.http.client.methods.*
import org.apache.http.impl.client.*
import org.apache.http.util.*
import java.io.*

fun main() {
	//不需要登录，不需要证书
	val url = "https://c-ssl.duitang.com/uploads/item/201408/19/20140819231206_sQjzM.jpeg"
	val filePath = "D:\\My Documents\\My Projects\\Study\\Kotlin-Study\\learn-kotlin-spam\\download\\cat.jpg"
	
	val httpClient = HttpClientBuilder.create().build()
	
	httpClient.use {
		val request = RequestBuilder.get(url).build()
		val response = httpClient.execute(request)
		File(filePath).writeBytes(EntityUtils.toByteArray(response.entity))
	}
}
